const http = require('http');
const {pingAll} = require('./pingInterface.js');
const {pingConfig} = require('../notifier.config');

function ipCheck() {
    const server = http.createServer(async function (request, response) {
        response.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        });
        await pingAll(res => {
            response.write(res);
        });
        response.end();
    })
    server.listen(pingConfig.port)
    console.log("ping 服务已启动: http://localhost:" + pingConfig.port + "");
}

module.exports = {
    ipCheck,
}
